<template>
  <div class="container">
    <a-card>
      <a-card-meta title="收款账户">
        <template #description
          >请配置你的提现收款账户，注意账户配置是否正确；如因账户配置错误造成您的损失，平台概不负责。</template
        >
      </a-card-meta>
      <div class="card-content">
        <div class="flex">
          <div>
            <img src="/image/icon5.png" alt="" />
            <span>微信</span>
          </div>
          <div>
            <span class="text">绑定账户：yu234927429</span>
            <a-button type="primary" @click="handleChange(1)">更换</a-button>
          </div>
        </div>
        <div class="flex">
          <div>
            <img src="/image/icon6.png" alt="" />
            <span>支付宝</span>
          </div>
          <div>
            <span class="text">绑定账户：yu234927429</span>
            <a-button type="primary" @click="handleChange(2)">更换</a-button>
          </div>
        </div>
        <div class="bank">
          <div class="flex">
            <div>
              <img src="/image/icon7.png" alt="" />
              <span>提现到银行卡</span>
            </div>
            <div>
              <a-button type="primary" @click="handleChange(3)">{{bankList.length>0 ?'更换':'去绑定'}}</a-button>
            </div>
          </div>
          <div class="list" v-for="item in bankList" :key="item.id">
            <p>银行名称：{{item.bankName}}</p>
            <p>绑定账户：{{item.bankCode}}</p>
            <p>开户名称：杨飞</p>
            <p>开户行地址：成都市武侯区鸿揾大街88号</p>
          </div>
        </div>
      </div>
    </a-card>
    <bankModal
      :show="show"
      :title="title"
      @handleSave="handleSave"
      @handleCancel="handleCancel"
    />
    <a-modal
      v-model:open="qrcodeShow"
      width="280px"
      :footer="null"
      :title="title"
      @cancel="handleClose"
    >
      <a-qrcode :value="qrcodeUrl" size="240" />
    </a-modal>
  </div>
</template>
<script setup>
import bankModal from "./components/bankModal.vue";
import { getUserBankCardList } from "@/api/config";
import { ref,onMounted } from "vue";
const show = ref(false);
const qrcodeShow = ref(false);
const title = ref("");
const qrcodeUrl = ref("https://www.antdv.com/");
function handleSave() {
  show.value = false;
}
function handleCancel() {
  show.value = false;
}
function handleChange(val) {
  if (val == 1) {
    title.value = "绑定微信";
    qrcodeShow.value = true;
  } else if (val == 2) {
    title.value = "绑定支付宝";
    qrcodeShow.value = true;
  } else {
    title.value = "绑定银行卡";
    show.value = true;
  }
}
function handleClose() {
  qrcodeShow.value = false;
}
const bankList = ref([]);
const getBankListFn = async () => {
  const result = await getUserBankCardList();
  if (result.code === 200) {
    bankList.value = result.data;
  }
};
onMounted(() => {
  getBankListFn()
})
</script>
<style lang="less" scoped>
.flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-content {
  margin-top: 24px;
  .flex {
    background-color: #f3f5f7;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 16px;
    img {
      width: 20px;
      height: 20px;
      margin-right: 4px;
    }
    .text {
      font-size: 12px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #262e47;
      line-height: 14px;
      margin-right: 12px;
    }
  }
  .bank {
    background-color: #f3f5f7;
    border-radius: 8px;
    padding-bottom: 24px;
    .flex {
      margin-bottom: 0;
      padding-bottom: 14px;
    }
    .list {
      padding: 0 24px;
      margin-bottom: 20px;
      p {
        font-size: 12px;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #262e47;
        line-height: 14px;
        margin-bottom: 8px;
      }
    }
  }
}
.empty {
  margin-top: 24px;
  background: #f3f5f7;
  border-radius: 8px;
  padding: 40px;
  text-align: center;
  img {
    width: 56px;
  }
  p {
    font-size: 14px;
    font-family: PingFang SC-Medium, PingFang SC;
    font-weight: 500;
    color: #262e47;
    line-height: 16px;
    margin: 24px 0;
  }
}
</style>
